-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add try/ref versions to unwrap #206
Conversation
There is a known issue with *_ref naming conflicts when an enum has SomeVariant and SomeVariantRef. |
I didn't look at the code in detail, but a few thoughts on the general design:
This seems rare enough that i wouldn't consider it a problem:
|
To clarify: The most open questions and discussion points for me are around the |
for 1 and 2: Yes, I will. I like the shortness of for 3 and 4: Makes sense. I just forgot that |
@rassvet2 are you still planning on making your suggested changes? |
I'm sorry I left this hanging for so long. |
It's ready for review. Finally, I decided like:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this looks good! But it needs a rebase with the current master branch. Quite a few things have changed in the file organization of the library since this PR was originally opened.
I'm wondering again if I should rename |
That's a really good point. I think you're right that TryUnwrap is probably the best name. Both |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good overal, just some small suggestions. Also there's a small merge conflict in the CHANGELOG.md now that #256 is merged which cleaned it up a bit.
Co-authored-by: Jelte Fennema <github-tech@jeltef.nl>
I extended Unwrap to add one that returns Option, one that returns reference, and a combination of the two, for my use.
It's ready to merge, but I don't think it's well discussed and considered.
try_unwrap_<variant>_ref
is... little uncool.So I'll leave it as a draft to solicit opinions.
This relates to #186.
var_a
looks better thantry_unwrap_var_a_ref
. But I think in that case it probably should not be implemented in Unwrap.Initially, I added it in Unwrap because it was tedious, but maybe it should be split into TryUnwrap, UnwrapRef, and TryUnwrapRef.
Is there anything else I have to do to be merged?